package cn.ruituo.web;

import cn.ruituo.service.StudentService;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;
import java.io.PrintWriter;

@WebServlet(name = "CheckPhoneServlet", value = "/checkPhoneServlet")
public class CheckPhoneServlet extends HttpServlet {
    protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        this.doPost(request, response);
    }

    protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        String phone = request.getParameter("phone");
        boolean repeat = StudentService.service.checkPhone(phone);
        //request.setAttribute("repat",repeat);
        //request.getRequestDispatcher()
        //给回应
        PrintWriter writer = response.getWriter();
        writer.print(repeat);
//        try {
//            Thread.sleep(5000);
//        } catch (InterruptedException e) {
//            e.printStackTrace();
//        }
        writer.flush();
    }
}
